package com.cy.demo523.untitled2.src.com.cy.dao523;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Scanner;

public class TestConnection {


    public static void main(String[] args) throws SQLException, ClassCastException, ClassNotFoundException {
        Scanner scanner = new Scanner(System.in);
        System.out.println("欢迎来到注册系统");
        System.out.println("请输入用户名");
        String username = scanner.next();
        System.out.println("请输入密码");
        String password = scanner.next();
        Connection connection = SqlCannection.getCon();
        String sql ="insert into users (username,password ) values (?,?)";
        PreparedStatement  preparedStatement  =connection .prepareStatement(sql) ;
        preparedStatement .setString(1,username) ;
        preparedStatement .setString(2,password) ;
        int i = preparedStatement.executeUpdate();
        if (i>0){
            System.out.println("注册成功");
             }
        else{
            System.out.println("注册失败");
        }
    }
}

